/**
 * 
 */
package com.primestone.cim.util;




/**
 * @author cesar.mateus
 *
 */
public class StringUtil {

	public static final String ORGANIZATION = "Pstone";
	public static final String SOURCE = "PrimeStone";

	public static final String TESTING_CONTEXT = "TESTING";
	public static final String PRODUCTION_CONTEXT = "PRODUCTION";
	
	public static final String DEFAULT_USER = "CIM";

	/**
	 * 
	 */
	public static final String DEFAULT_REVISION = "1";

	public static final String TICKET_FIELD_NAME = "ticket";
	public static final String SOCKET_FIELD_NAME = "socket";
	public static final String DEVICE_FIELD_NAME = "device";
	public static final String VAR_FIELD_NAME = "descvar";
	public static final String VARTYPE_FIELD_NAME = "vartype";
	public static final String TOP_NAME = "top";

	/**
	 * oldBlock
	 */
	public static final String OLD_BLOCK_NAME = "oldBlock";
	public static final String BATCH_NAME = "batch";

	public static final String ONLY_NEW_READINGS = "onlyNew";
	public static final String CLIENT_FIELD_NAME = "client";
	public static final String UOM_FIELD_NAME = "uom";
	public static final String CHANNEL_FIELD_NAME = "channel";
	public static final String INTERVAL_FIELD_NAME = "interval";
	public static final String KE_FIELD_NAME = "ke";
	public static final String USAGEDATA_FIELD_NAME = "usagedata";

	public static final String ID_BLOCK = "idBlock";
	public static final String USER = "user";
	public static final String RESULT_DATE = "resultDate";
	public static final String TICKET = "ticket";
	public static final String LAST_BLOCK = "lastBlock";

	public static final String VARTYPE_LP = "M";
	public static final String VARTYPE_REG = "R";
	public static final String VARTYPE_EVE = "V";

	public static final String CREATE_OPERATION = "C";
	public static final String UPDATE_OPERATION = "U";
	public static final String DELETE_OPERATION = "D";

	public static final String _NULL_STRING_ = "ND";
	public static final Boolean _NULL_BOOLEAN_ = null;
	public static final String ENCODING = "ISO-8859-1";
	public static final String ENCODING_UTF8 = "UTF-8";

	public static final String DOT = ".";
	public static final String BLANK = " ";
	public static final String COMMA = ",";
	public static final String EMPTY = "";
	public static final String UNDERSCORE = "_";
	public static final String DASH = "-";
	public static final String DELIMITER = DOT;

	public static final String NO = "No";

	public static final String CIM_EXPORT = "CIM Export";
	public static final String CAUSE = "Cause: ";
	public static final String MESSAGE = "Message: ";
	public static final String SCHEDULED = "-2";
	public static final String NOT_ID_BLOCK = "-1";

	public static final String OK = "OK";
	public static final String PWD_PROP_NAME = "pwd";

	public static final String CONN_FACTORY_JNDI_NAME = "java:/JmsXA";
	public static final String DESTINATION_EXEC_EDC_QUEUE = "java:jboss/exported/jms/queue/CIMExecEndDeviceControlsQueue";
	public static final String DESTINATION_EXEC_MRS_QUEUE = "java:jboss/exported/jms/queue/CIMExecMeterReadSchedulesQueue";
	public static final String DESTINATION_GET_MR_QUEUE = "java:jboss/exported/jms/queue/CIMGetMeterReadingsQueue";
	public static final String QUEUE_DEST_TYPE = "javax.jms.Queue";
	public static final String ACK_MODE = "Auto-acknowledge";
	public static final String RES_ADAPTER = "hornetq-ra.rar";
	public static final String RES_DS = "java:/cimsqlserverds";
	public static final String TMPTABLEEJB_BEAN_NAME = "TmpTableEJB";
	public static final String TMPTABLEEJB_MAPPED_NAME = "TmpTableEJB";
	public static final String TMPTABLEEJB_NAME = "TmpTableEJB";
	public static final String PERSISTENCE_UNIT = "TmpTablesGMR";
	public static final String QUEUEUPEXECEDC_NAME = "QueueUpExeEDC";
	public static final String QUEUEUPEXECMRS_NAME = "QueueUpExeMRS";
	public static final String QUEUEUPGETMR_NAME = "QueueUp";

	public static final String WORD = "G3h31mn1s kl31n3s m31n";
	public static final String ERROR_INDICATOR = "---- ERROR: ";
	
	public static final String EMPTY_CIM_CODE = "0.0.0.0.0.0.0.0.0.0.0";
	
	public static final String PREFIX_BATCH_FILES = "mrpt-";
	public static final String PREFIX_OLD_BATCH_FILES = "old-";
	public static final String SUFFIX_BATCH_FILES = ".xml";
	
	public static final String SUFFIX_ZIPPED_BATCH_FILES = ".zip";
	public static final String STATUS_OK = StringUtil.OK;
	
	
	
	/**
	 * 
	 * @param string
	 * @return
	 */
	public static boolean safe(String string) {
		if( string == null || string.trim().equals(EMPTY) ) {
			return false;
		}
		return true;
	}

	/**
	 * 
	 * @param description
	 * @param cause
	 * @param message
	 * @return
	 */
	public static String composeMessageServiceException(String description, Throwable e) {
		return new StringBuilder(ERROR_INDICATOR).append(description).append(StringUtil.DOT).append(StringUtil.BLANK)
				.append(StringUtil.CAUSE).append(e.getCause()).append(StringUtil.DOT).append(StringUtil.BLANK)
				.append(StringUtil.MESSAGE).append(e.getMessage()).append(StringUtil.DOT).toString();
	}
	
	/**
	 * 
	 * @param description
	 * @return
	 */
	public static String composeMessageServiceException(String description) {
		return new StringBuilder(ERROR_INDICATOR).append(description).toString();
	}
	
}
